package edu.msoe.se3811.jmlunit.testcases;

import java.util.NoSuchElementException;

import edu.msoe.se3811.jmlunit.code.wordnum.WordNumber;

public class TestDataGenerator_JML_Test {

	/**
	 * Test data generator for integer (int) values.
	 * It is called by the JML/JUnit test framework when an int value
	 * is needed for a test.
	 * 
	 * @return array of integer test values
	 */
	public static int[] getIntArray() {
		return new int[] {
				0, 1, 2, 126, 127, 128, 129, Integer.MAX_VALUE,
				-1, -2
				};
	}

	/**
	 * Test data generator for String values.
	 * It is called by the JML/JUnit test framework when a String value
	 * is needed for a test.
	 * 
	 * @return array of String test values
	 */
	public static String[] getStringArray() {
		return new String[] {
				null,
				"",
				" ",
				"five",
				"six"
				
				};
	}
	
	/**
	 * Test data generator for WordNumber values.
	 * It is called by the JML/JUnit test framework when a WordNumber value
	 * is needed for a test.
	 * 
	 * @param valueIndex index (0..?) to select a test value
	 * @return test value corresponding to the index
	 */
	public static WordNumber getWordNumber(int valueIndex) {
		String stringValue = null;
		boolean valueOk = true;

		switch (valueIndex) {
		case 0:
			stringValue = "zero";
			break;
		case 1:
			stringValue = "one";
			break;
		case 2:
			stringValue = "two";
			break;
		case 3:
			stringValue = "three";
			break;
		case 4:
			stringValue = "four";
			break;
		case 5:
			stringValue = "five";
			break;
		case 6:
			stringValue = "six";
			break;
		case 7:
			stringValue = "seven";
			break;
		case 8:
			stringValue = "eight";
			break;
		case 9:
			stringValue = "nine";
			break;
		case 10:
			stringValue = "ten";
			break;
		
		default:
			valueOk = false;
		}
		
		// If the value index does not correspond to a valid test value,
		// throw an exception to notify the JML/JUnit framework.
		if (!valueOk) {
			throw new NoSuchElementException();
		}
		
		// Otherwise, return the requested value.
		WordNumber returnVal = new WordNumber(stringValue);
		return returnVal;
	}
	
}
